<template>
	<view class="goods-item">
		<!-- 左边区域 -->
		<view class="goods-left">
			<!-- 图片区域 -->
			<image :src="goods.goods_small_logo || defaultPic" mode=""></image>
		</view>
		<!-- 右边区域 -->
		<view class="goods-right">
			<!-- 标题区域 -->
			<view class="goods-title">{{goods.goods_name}}</view>
			<!-- 价格区域 -->
			<view class="goods-price">{{goods.goods_price | formatPrice}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "my-goods",
		props: {
			goods: {
				type: Object,
				default: () => ({})
			}
		},
		data() {
			return {
				// 默认图片
				defaultPic: 'https://img1.baidu.com/it/u=117938972,521936855&fm=253&fmt=auto&app=138&f=JPEG?w=1201&h=500'
			};
		},
		filters: {
			formatPrice(price) {
				return Number(price).toFixed(2)
			}
		}
	}
</script>

<style lang="scss">
	// 商品列表项
	.goods-item {
		display: flex;
		padding: 0 5px;
		border-bottom: 5px solid #efefef;

		// 左边区域
		.goods-left {
			image {
				height: 100px;
				width: 100px;
				display: block;
			}
		}

		// 右边区域
		.goods-right {
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.goods-title {
				font-size: 13px;
				text-align: justify;
			}

			.goods-price {
				display: flex;
				justify-content: space-between;
				color: #d81e06;
				font-size: 16px;
			}
		}
	}
</style>